const express = require('express');
const app = express();
const mongo = require('../dataBase/users');
const router = express.Router();
const bodyParser = require('body-parser');
const jsonParser = bodyParser.json();
router.post('/', jsonParser, (req, res) => {
    mongo.Users.find({ userId: req.body.userId }, (err, docu) => {
        if (err) {
            res.send({ status: false });
            return
        }

        return docu
    }).then((docu) => {
        if (docu.length != 0) {
            console.log(`user's password is : ${docu[0].password}`);
            if (docu[0].password == req.body.password) {
                console.log(`user's password is : ${docu[0].password}`);
                res.send({ status: true });
            } else {
                res.send({ status: false });
            }
        } else {
            res.send({ status: false });
        }
    })
})

module.exports = router;